package desginmode.single

/**
 * 非线程安全，懒加载(Lazy单例)
 */
class NotThreadSafeSingle private constructor() {

    fun getName() = "NotThreadSafeSingle"

    companion object {
        //lazy关键字(懒加载) LazyThreadSafetyMode：懒加载线程模式
        val instance by lazy(LazyThreadSafetyMode.NONE) {
            NotThreadSafeSingle()
        }
    }
}

fun main(args: Array<String>) {
    print(NotThreadSafeSingle.instance.getName())
}